// CodeScienceFooter.js
import { Footer } from "./Footer.js";
import footerCss from "../../assets/css/style.css"; // 假设使用 raw-loader 加载 CSS 文件

class CodeScienceFooter extends HTMLElement {
  constructor() {
    super();
    this.attachShadow({ mode: "open" });
  }

  connectedCallback() {
    const year = this.getAttribute("year") || new Date().getFullYear();
    const companyName = this.getAttribute("company-name") || "Code Science";
    const designer = this.getAttribute("designer") || "Alan.Luo";
    const designerLink = this.getAttribute("designer-link") || "#";

    const footer = new Footer({
      year,
      companyName,
      designer,
      designerLink,
    });

    const footerElement = footer.render();

    // 创建 style 元素并添加 CSS 内容
    const style = document.createElement("style");
    style.textContent = footerCss;
    this.shadowRoot.appendChild(style);
    this.shadowRoot.appendChild(footerElement);
  }
}

customElements.define("code-science-footer", CodeScienceFooter);
